﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DataLibrary
{
    public class Ctbl_Category_Lang:IData<tbl_Category_Lang>
    {
        public Ctbl_Category_Lang() { }
        public Ctbl_Category_Lang(String myconnecString) : base(myconnecString) { 
        }

        public override List<tbl_Category_Lang> GetAll(tbl_Category_Lang item)
        {
            throw new NotImplementedException();
        }

        public override tbl_Category_Lang GetItemById(object id)
        {
            throw new NotImplementedException();
        }

        public override tbl_Category_Lang GetItem(System.Data.IDataReader dr)
        {
            tbl_Category_Lang obj = new tbl_Category_Lang();
            obj.Description = Convert.ToString(dr[tbl_Category_Lang.c_Description]);
            obj.IdCat = Convert.ToInt32(dr[tbl_Category_Lang.c_idCat]);
            obj.IdCatLang = Convert.ToInt32(dr[tbl_Category_Lang.c_idCatLang]);
            obj.IdLang = Convert.ToInt32(dr[tbl_Category_Lang.c_idLang]);
            obj.NameCat = Convert.ToString(dr[tbl_Category_Lang.c_nameCat]);
            obj.Url = Convert.ToString(dr[tbl_Category_Lang.c_Url]);
            return obj;
        }

        public override List<tbl_Category_Lang> GetAll()
        {
            throw new NotImplementedException();
        }

        public List<tbl_Category_Lang> GetListByIdPrimary(int id)
        {

            List<tbl_Category_Lang> list = GetListParameter("GetListByIdPrimary", CommandType.StoredProcedure,
                new SqlParameter("@" + tbl_Category_Lang.c_idCat,id));
            return list;
        }

        protected override int InsertOnSubmit(tbl_Category_Lang item, int t)
        {
            int id = -1;
            id=connec.ExecuteNonQuery("CRUDCategoryLang", CommandType.StoredProcedure, new SqlParameter("@flag", t),
                new SqlParameter("@"+tbl_Category_Lang.c_Description,item.Description),new SqlParameter("@"+tbl_Category_Lang.c_idCat,item.IdCat),
                new SqlParameter("@"+tbl_Category_Lang.c_idCatLang,item.IdCatLang),new SqlParameter("@"+tbl_Category_Lang.c_idLang,item.IdLang),
                new SqlParameter("@"+tbl_Category_Lang.c_nameCat,item.NameCat),new SqlParameter("@"+tbl_Category_Lang.c_Url,item.Url));
            return id;
        }

    }
}
